home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume8 / gnuplot1.10A / part07 < prev    next >
Encoding:
Text File  |  1989-09-09  |  46.5 KB  |  1,817 lines

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Subject: v08i041: GnuPlot v1.10A (part 7 of 7)
  4. Reply-To: canoaf@ntvax.UUCP (Augustine Cano)
  5.  
  6. Posting-number: Volume 8, Issue 41
  7. Submitted-by: canoaf@ntvax.UUCP (Augustine Cano)
  8. Archive-name: gnuplot1.10A/part07
  9.  
  10. [OOPS!!!  I had to patch these after receiving them -- and managed to lose the
  11. name of the person who submitted them in the process.  Duh.  The name shown
  12. is a "best guess".  Submitter, please correct me.  ++bsa]
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 7 (of 7)."
  21. # Contents:  docs/helptree.c docs/hlp2ms.c docs/intro docs/termdrvr.doc
  22. #   docs/titlepage help help/README help/append.c help/catch.c
  23. #   help/format_help.c help/free_list.c help/global.h help/help.1
  24. #   help/help.c help/initialize.c help/input_choice.c help/insert.c
  25. #   help/link.otc help/main.c help/makefile.tc help/makefile.unx
  26. #   help/pchar.c help/present.c help/scan_topics.c
  27. # Wrapped by allbery@uunet on Sat Sep  9 13:47:25 1989
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'docs/helptree.c' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'docs/helptree.c'\"
  31. else
  32. echo shar: Extracting \"'docs/helptree.c'\" \(6341 characters\)
  33. sed "s/^X//" >'docs/helptree.c' <<'END_OF_FILE'
  34. X#include <stdio.h>
  35. X#include <ctype.h>
  36. X#ifndef __TURBOC__
  37. X#include <sys/file.h>
  38. X#endif
  39. X#include <sys/types.h>
  40. X#include <sys/stat.h>
  41. X
  42. Xextern errno, sys_nerr;
  43. Xextern char *sys_errlist[];
  44. X
  45. X#define ErrOut(s1,s2) {\
  46. Xfprintf(stderr, "\n%s:: ", sys_errlist[errno]);\
  47. Xfprintf(stderr, s1, s2);\
  48. Xfprintf(stderr, "\n");\
  49. Xexit(1);}
  50. X
  51. Xmain(argc,argv)
  52. Xint argc;
  53. Xchar *argv[];
  54. X/*
  55. X   Routine to build a flat file out of a help tree or build a help tree
  56. X   out of a flat file.  This routine requires a switch (-f or -t) to
  57. X   determine which mode it will run in and a path name that represents
  58. X   the root of a help tree.  A flat help file is useful for moving a
  59. X   help tree from one system to another and, in addition, VMS can use
  60. X   it directly as a help file.
  61. X
  62. X   -f assume we are creating a flat file, path is the root of an existing
  63. X      help tree and the flat help file will be written to stdout.
  64. X
  65. X   -t assume we are creating a help tree, path is the root of a help tree
  66. X      that is to be created.
  67. X
  68. X   usage: helptree -f path       or      helptree -t path
  69. X
  70. X*/
  71. X{
  72. X
  73. X/* Parse options. */
  74. X   if (argc != 3 || argv[1][0] != '-') usage();
  75. X   if (argv[1][1] == 'f')
  76. X      build_file (argv[2], 0);
  77. X   else if (argv[1][1] == 't')
  78. X      build_tree (argv[2]);
  79. X
  80. X   exit (0);
  81. X/*NOTREACHED*/
  82. X}
  83. X
  84. X
  85. Xbuild_file (path,level)
  86. Xchar *path;
  87. Xint level;
  88. X{
  89. X   FILE *fp, *fopen();
  90. X   char buf[BUFSIZ], name[BUFSIZ];
  91. X   char *names, *src, *dst, *str_append(), *next_name();
  92. X
  93. X   ++level;
  94. X   if (chdir(path) < 0)
  95. X      ErrOut("Can't cd to %s", path);
  96. X
  97. X/* Copy any TEXT file out to stdout. */
  98. X   if ((fp = fopen ("TEXT", "r")) != NULL) {
  99. X      while (fgets (buf, BUFSIZ, fp) != NULL) {
  100. X     putc (' ', stdout);  /* Put leading space on output lines */
  101. X         fputs (buf, stdout);
  102. X      }
  103. X      fclose (fp);
  104. X   }
  105. X   names = NULL;
  106. X
  107. X/* Read any DIR file and build a list of names. */
  108. X   if ((fp = fopen ("DIR", "r")) != NULL) {
  109. X      while (fgets (buf, BUFSIZ, fp) != NULL) {
  110. X         src = buf;
  111. X         dst = name;
  112. X         while (*src && *src != '*') *dst++ = *src++;
  113. X         if (*src == '*') {
  114. X         /* Append this name to the end of the name list. */
  115. X            *dst = '\0';
  116. X            names = str_append (names, name);
  117. X         }
  118. X      }
  119. X      fclose (fp);
  120. X   }
  121. X/* Cycle through the names and do each one found. */
  122. X   src = names;
  123. X   while ((src = next_name (src, name)) != NULL) {
  124. X      if (isdirectory(name)) {
  125. X         printf ("%d %s\n", level, name);
  126. X         build_file (name, level);  /* Recurse. */
  127. X         if (chdir ("..") < 0)
  128. X            ErrOut ("Error with cd ..", NULL);
  129. X      }
  130. X   }
  131. X}
  132. X
  133. X
  134. Xstatic int lncnt=0, done=0;  /* Set in put_text */
  135. Xstatic char buf[BUFSIZ];
  136. X
  137. Xbuild_tree (start_path)
  138. Xchar *start_path;
  139. X/*
  140. X   This routine assumes that a properly formatted .hlp file is being read
  141. X   in from standard input.  Properly formatted means that the only lines
  142. X   which begin in column 1 are numeric indices of a tree (directory) 
  143. X   level.
  144. X*/
  145. X{
  146. X   int level, curlevel=0;
  147. X   char cmd[256], *ptr, path[BUFSIZ];
  148. X   
  149. X   strcpy (path, start_path);
  150. X   while (!done) {
  151. X      sprintf (cmd,"mkdir %s", path);
  152. X      system (cmd); 
  153. X      if (curlevel > 0)
  154. X         append_DIR (path);
  155. X      if (chdir(path) < 0)
  156. X         ErrOut("Can't cd to %s", path);
  157. X      ++curlevel;
  158. X
  159. X      put_text ("TEXT");
  160. X   /* Buf now contains new level item or we reached EOF */
  161. X      if (done) break;
  162. X
  163. X      level = atoi (buf);
  164. X      ptr = buf;
  165. X      while (isspace(*ptr) || isdigit(*ptr)) ++ptr;
  166. X      ptr[strlen(ptr)-1] = '\0';  /* Remove \n */
  167. X      strcpy (path, ptr);
  168. X
  169. X      while (curlevel > level) {
  170. X         if (chdir("..") < 0)
  171. X            ErrOut("Can't cd to ..", path);
  172. X         if (--curlevel < 1) {
  173. X            fprintf (stderr, "Error with input near line %d\n",lncnt);
  174. X            exit(1);
  175. X         }
  176. X      }
  177. X   }
  178. X}
  179. X
  180. Xappend_DIR (path)
  181. Xchar *path;
  182. X/*
  183. X   Append ``path'' to the DIR file found at this directory level.
  184. X*/
  185. X{
  186. X   FILE *fdir, *fopen();
  187. X
  188. X   if ((fdir = fopen ("DIR", "a")) == NULL) {
  189. X      fprintf (stderr, "Couldn't build DIRS near line %d\n", lncnt);
  190. X      ErrOut ("Open failure for DIRS in %s", path);
  191. X   }
  192. X   fprintf (fdir, "%s*%s\n", path, path);
  193. X   fclose (fdir);
  194. X}
  195. X
  196. X
  197. Xput_text (file)
  198. Xchar *file;
  199. X{
  200. X   FILE *ftext = NULL, *fopen();
  201. X   char *bufptr;
  202. X
  203. X   while ((bufptr = fgets (buf, BUFSIZ, stdin)) != NULL) {
  204. X      ++lncnt;
  205. X      if (!isspace(buf[0])) {
  206. X         break;
  207. X      }
  208. X   /* Open the file the first time we have to write to it. */
  209. X      if (ftext == NULL) {
  210. X         if ((ftext = fopen (file, "w")) == NULL) 
  211. X            ErrOut ("Can't open TEXT file near line %d in input", lncnt);
  212. X      }
  213. X      fputs (buf+1, ftext);  /* Don't write first blank */
  214. X   }
  215. X   if (ftext != NULL)
  216. X      fclose(ftext);
  217. X   if (bufptr == NULL) {
  218. X      done = 1;
  219. X   }
  220. X}
  221. X
  222. X
  223. Xint isdirectory(name)
  224. Xchar *name;
  225. X{
  226. X   struct stat sbuf;
  227. X   int isdir=1;
  228. X   
  229. X   if (stat(name,&sbuf) < 0) {
  230. X      isdir = 0;
  231. X      fprintf (stderr, "Can't stat %s\n", name);
  232. X   }
  233. X
  234. X   if (!(sbuf.st_mode & S_IFDIR)) {
  235. X      isdir = 0;
  236. X      fprintf (stderr, "%s is not a directory!\n", name);
  237. X   }
  238. X   return isdir;
  239. X}
  240. X
  241. X
  242. Xchar *next_name (src, name)
  243. Xchar *src, *name;
  244. X/*
  245. X   Routine to store next name in src into and then return pointer to next
  246. X   name.  src is a list of names separated by a ' '.
  247. X*/
  248. X{
  249. X   char *dst=name;
  250. X
  251. X   if (!*src) return NULL;
  252. X
  253. X   while (*src && *src != ' ') *dst++ = *src++;
  254. X
  255. X   *dst = '\0';
  256. X
  257. X   if (dst == name) return NULL;
  258. X
  259. X   while (*src == ' ') ++src;
  260. X
  261. X   return src;
  262. X}
  263. X
  264. X
  265. Xchar *str_append (names, name)
  266. Xchar *names, *name;
  267. X/*
  268. X   Routine to stick name into the names list.
  269. X*/
  270. X{
  271. X   char *realloc(), *malloc();
  272. X   int l1=0, l2;
  273. X
  274. X   if (names != NULL)
  275. X      l1 = strlen(names);
  276. X   else
  277. X      l1 = -1;
  278. X
  279. X   l2 = strlen(name);
  280. X
  281. X   if (names == NULL)
  282. X      names = malloc ((unsigned )l1+l2+2);
  283. X   else
  284. X      names = realloc (names, (unsigned )l1+l2+2);
  285. X
  286. X   if (l1 > 0)
  287. X      names[l1] = ' ';
  288. X   
  289. X   strcpy (&names[l1+1], name);
  290. X
  291. X   return names;
  292. X}
  293. X
  294. X
  295. Xusage()
  296. X{
  297. X   fprintf (stderr, "usage: helptree -f path\tor\thelptree -t path\n\n");
  298. X   fprintf (stderr,
  299. X   "-f assume we are creating a flat file, path is the root of an existing\n");
  300. X   fprintf (stderr,
  301. X   "   help tree and the flat help file will be written to stdout.\n\n");
  302. X
  303. X   fprintf (stderr,
  304. X   "-t assume we are creating a help tree, path is the root of a help tree\n");
  305. X   fprintf (stderr,"   that is to be created.\n");
  306. X
  307. X   exit(1);
  308. X}
  309. END_OF_FILE
  310. if test 6341 -ne `wc -c <'docs/helptree.c'`; then
  311.     echo shar: \"'docs/helptree.c'\" unpacked with wrong size!
  312. fi
  313. # end of 'docs/helptree.c'
  314. fi
  315. if test -f 'docs/hlp2ms.c' -a "${1}" != "-c" ; then 
  316.   echo shar: Will not clobber existing file \"'docs/hlp2ms.c'\"
  317. else
  318. echo shar: Extracting \"'docs/hlp2ms.c'\" \(2140 characters\)
  319. sed "s/^X//" >'docs/hlp2ms.c' <<'END_OF_FILE'
  320. X/*
  321. X * hlp2ms.c  -- program to convert VMS .HLP format to *roff -ms document
  322. X * Thomas Williams 
  323. X *
  324. X * usage:  hlp2ms < file.hlp > file.ms
  325. X *
  326. X *   where file.hlp is a VMS .HLP file, and file.ms will be a [nt]roff
  327. X *     document suitable for printing with nroff -ms or troff -ms
  328. X *
  329. X * typical usage for GNUPLOT:
  330. X *
  331. X *   vmshelp.csh /usr/help/gnuplot/* | hlp2ms | troff -ms
  332. X */
  333. X
  334. X#include <stdio.h>
  335. X#include <ctype.h>
  336. X
  337. X#define MAX_NAME_LEN    256
  338. X#define MAX_LINE_LEN    256
  339. X#define LINE_SKIP        3
  340. X
  341. X
  342. Xmain()
  343. X{
  344. X    init(stdout);
  345. X    convert(stdin,stdout);
  346. X    finish(stdout);
  347. X    exit(0);
  348. X}
  349. X
  350. X
  351. Xinit(b)
  352. XFILE *b;
  353. X{
  354. X            /* in nroff, increase line length by 8 and don't adjust lines */
  355. X    (void) fputs(".if n \\{.nr LL +8m\n.na \\}\n",b);
  356. X    (void) fputs(".nr PO +0.3i\n",b);
  357. X    (void) fputs(".so titlepage\n",b);
  358. X    (void) fputs(".pn 1\n",b);
  359. X    (void) fputs(".ds CH GNUPLOT\n",b);
  360. X    (void) fputs(".ds RH Page %\n",b);
  361. X    (void) fputs(".bp\n",b);
  362. X    (void) fputs(".nr PS 12\n",b);
  363. X    (void) fputs(".nr VS 13\n",b);
  364. X    (void) fputs(".ta 1.5i 3.0i 4.5i 6.0i 7.5i\n",b);
  365. X    (void) fputs("\\&\n.sp 3\n.PP\n",b);
  366. X    (void) fputs(".so intro\n",b);
  367. X}
  368. X
  369. X
  370. Xconvert(a,b)
  371. XFILE *a,*b;
  372. X{
  373. Xstatic char string[MAX_LINE_LEN],line[MAX_LINE_LEN];
  374. Xint old = 1;
  375. Xint sh_i, i;
  376. X
  377. X    while (fgets(line,MAX_LINE_LEN,a)) {
  378. X
  379. X        if (isdigit(line[0])) {
  380. X            (void) sscanf(line,"%d %[^\n]s",&sh_i,string);
  381. X
  382. X            (void) fprintf(b,".sp %d\n",(sh_i == 1) ? LINE_SKIP : LINE_SKIP-1);
  383. X
  384. X            if (sh_i > old) {
  385. X                do
  386. X                    (void) fputs(".RS\n.IP\n",b);
  387. X                while (++old < sh_i);
  388. X            }
  389. X            else if (sh_i < old) {
  390. X                do
  391. X                    (void) fputs(".RE\n.br\n",b);
  392. X                while (--old > sh_i);
  393. X            }
  394. X
  395. X            (void) fprintf(b,".NH %d\n%s\n.sp 1\n.LP\n",sh_i,string);
  396. X            old = sh_i;
  397. X
  398. X            (void) fputs(".XS\n",b);
  399. X            (void) fputs(string,b);
  400. X            (void) fputs("\n.XE\n",b);
  401. X
  402. X        } else {
  403. X            switch (line[1]) {
  404. X                case ' ' : fputs(".br\n",b); fputs(line+1,b); fputs(".br\n",b);
  405. X                            break;
  406. X                case '\'': fputs("\\&",b);
  407. X                default  : (void) fputs(line+1,b); 
  408. X            }
  409. X        }
  410. X
  411. X    }
  412. X}
  413. X
  414. X
  415. Xfinish(b)        /* spit out table of contents */
  416. XFILE *b;
  417. X{
  418. X    (void) fputs(".pn 1\n",b);
  419. X    (void) fputs(".ds RH %\n",b);
  420. X    (void) fputs(".af % i\n",b);
  421. X    (void) fputs(".bp\n.PX\n",b);
  422. X}
  423. END_OF_FILE
  424. if test 2140 -ne `wc -c <'docs/hlp2ms.c'`; then
  425.     echo shar: \"'docs/hlp2ms.c'\" unpacked with wrong size!
  426. fi
  427. # end of 'docs/hlp2ms.c'
  428. fi
  429. if test -f 'docs/intro' -a "${1}" != "-c" ; then 
  430.   echo shar: Will not clobber existing file \"'docs/intro'\"
  431. else
  432. echo shar: Extracting \"'docs/intro'\" \(24 characters\)
  433. sed "s/^X//" >'docs/intro' <<'END_OF_FILE'
  434. X
  435. X.B
  436. X.ce
  437. XINTRODUCTION
  438. X.R
  439. END_OF_FILE
  440. if test 24 -ne `wc -c <'docs/intro'`; then
  441.     echo shar: \"'docs/intro'\" unpacked with wrong size!
  442. fi
  443. # end of 'docs/intro'
  444. fi
  445. if test -f 'docs/termdrvr.doc' -a "${1}" != "-c" ; then 
  446.   echo shar: Will not clobber existing file \"'docs/termdrvr.doc'\"
  447. else
  448. echo shar: Extracting \"'docs/termdrvr.doc'\" \(2024 characters\)
  449. sed "s/^X//" >'docs/termdrvr.doc' <<'END_OF_FILE'
  450. XHere's a brief description of what each term.c procedure does:
  451. X
  452. X_init()  Called once, when the device is first selected.  This procedure
  453. Xshould set up things that only need to be set once, like handshaking and
  454. Xcharacter sets etc...
  455. X
  456. X_graphics()  Called just before a plot is going to be displayed.  This
  457. Xprocedure should set the device into graphics mode.  Devices which can't
  458. Xbe used as terminals (like plotters) will probably be in graphics mode always
  459. Xand therefore won't need this.
  460. X
  461. X_text()  Called after a plot is displayed.  This procedure should set the
  462. Xdevice back into text mode if it is also a terminal, so that commands can
  463. Xbe seen as they're typed.  Again, this will probably do nothing if the
  464. Xdevice can't be used as a terminal.
  465. X
  466. X_linetype(lt)  Called to set the line type before text is displayed or line(s)
  467. Xplotted.  This procedure should select a pen color or line style if the
  468. Xdevice has these capabilities.  lt is an integer from -2 to 8.  An lt of
  469. X-2 is used for the border of the plot.  An lt of -1 is used for the X and Y
  470. Xaxes.  lt 0 through 8 are used for plots 0 through 8.
  471. X
  472. X_move(x,y)  Called at the start of a line.  The cursor should move to the
  473. X(x,y) position without drawing.
  474. X
  475. X_vector(x,y)  Called when a line is to be drawn.  This should display a line
  476. Xfrom the last (x,y) position given by _move() or _vector() to this new (x,y)
  477. Xposition.
  478. X
  479. X_ulput_text(row,str)  Called to display text in the upper-left corner of
  480. Xthe screen/page.  row is an integer from 0 through 8.  The row starts
  481. Xat the upper-left with 0 and proceed down.  str is the string to be displayed.
  482. X
  483. X_lrput_text(row,str)  Called to display text in the lower-right corner of
  484. Xthe screen/page.  This is the same as ulput_text(), except that the string
  485. Xshould be displayed right-justified in the lower right corner of the screen.
  486. XThe row starts at the lower-right with 0 and proceeds up.
  487. X
  488. X_reset()  Called when Gnuplot is exited.  This procedure should reset the
  489. Xdevice, possibly flushing a buffer somewhere or generating a form feed.
  490. END_OF_FILE
  491. if test 2024 -ne `wc -c <'docs/termdrvr.doc'`; then
  492.     echo shar: \"'docs/termdrvr.doc'\" unpacked with wrong size!
  493. fi
  494. # end of 'docs/termdrvr.doc'
  495. fi
  496. if test -f 'docs/titlepage' -a "${1}" != "-c" ; then 
  497.   echo shar: Will not clobber existing file \"'docs/titlepage'\"
  498. else
  499. echo shar: Extracting \"'docs/titlepage'\" \(216 characters\)
  500. sed "s/^X//" >'docs/titlepage' <<'END_OF_FILE'
  501. X.nr HM 3.2i
  502. X.TL
  503. XGNUPLOT
  504. X.br
  505. XAn Interactive Plotting Program
  506. X.sp
  507. X.AU
  508. XThomas Williams & Colin Kelley
  509. X.AI
  510. XDepartment of Electrical Engineering 
  511. XVillanova University
  512. XVillanova, PA  19085
  513. X\*(DY
  514. X.AB no
  515. X.AE
  516. X.LP
  517. X.nr HM 1.2i
  518. END_OF_FILE
  519. if test 216 -ne `wc -c <'docs/titlepage'`; then
  520.     echo shar: \"'docs/titlepage'\" unpacked with wrong size!
  521. fi
  522. # end of 'docs/titlepage'
  523. fi
  524. if test ! -d 'help' ; then
  525.     echo shar: Creating directory \"'help'\"
  526.     mkdir 'help'
  527. fi
  528. if test -f 'help/README' -a "${1}" != "-c" ; then 
  529.   echo shar: Will not clobber existing file \"'help/README'\"
  530. else
  531. echo shar: Extracting \"'help/README'\" \(4091 characters\)
  532. sed "s/^X//" >'help/README' <<'END_OF_FILE'
  533. XHello,
  534. X
  535. XThis is the first distribution of any sort out of me.  This program,
  536. XI believe, will find genuine use on almost all machines, versions of
  537. XUN*X, and environments.  This system implements a VMS-like help facility
  538. Xfor any and all commands, procedures, etc.
  539. X
  540. XI hereby release this code into the public domain.  Please don't remove
  541. Xthe file headers that have my name in them, and don't make profit with
  542. Xthis system.  Rather, customize it to your own local uses and
  543. X
  544. X        TEACH PEOPLE UN*X WITH THIS SYSTEM!!!
  545. X
  546. XThis later goal is by FAR more important to me than some stupid copyright
  547. Xnotice that could be deleted by anyone anyway.  Also, I will not be libel
  548. Xfor any damages done to your system, period.  AS IS WHERE IS is the motto.
  549. X
  550. XThis system is NOT intended to replace "man(1)" but rather to supplement
  551. Xthe information in the manual pages to first time users.  For instance,
  552. Xhere at OSU, we use this system on the undergraduate machine to try and
  553. Xguide the freshman through the gore of printing, editors, etc. rather
  554. Xthan having a professor do it.  Also, most of the more often used
  555. Xcommands have their manual pages ripped up and stuffed into this format
  556. Xto aid the student (you must admit that "help" is a more natural thing
  557. Xto type when in need as a first time UN*X user than is "man").
  558. X
  559. XBecause we have 43 hosts here in the Computer and Information Sciences
  560. Xdepartment, all running some flavor of UN*X, a LARGE amount of time
  561. Xwas taken to make this as simple and portable as possible.  Therefore,
  562. X"curses(3)" was not used (not all systems support it in the same way
  563. Xor even have it in a few cases).  Also things like ISAM were not used
  564. X(portability problems).  This implies that this package does not have
  565. Xthe 'spiffyness' that some of you may be looking for.
  566. X
  567. XIn short, this is not going to impress the boss, code-wise.  Rather, the
  568. Xcontent of the help directorys (the actual text of the various help
  569. Xmessages) are what should be devoted a fair amount of time.  This is also
  570. Xwhere this system shines.  True flexibility is achieved by the "DIR" files
  571. Xwithin this system.  They allow you to setup acronyms for traversing the
  572. Xdirectory tree of "TEXT" files.  This allows you to have help topics like
  573. X"printing a file" or "using the printer in the basement" both point to
  574. Xthe help screen on using the "lp" command.  This file also allows SYS5
  575. Xsites to use any length 'help file' name and still map it into the small
  576. Xfile name SYS5 allows you (14 characters?).
  577. X
  578. XHidden aliases can also be used.  This allows you to also have such things
  579. Xas "lp" be a 'help topic' as in the previous paragraph.  This makes the
  580. Xsystem less painful for those who really do know UN*X, but have forgotten
  581. Xone simple flag on "_XXXX_".
  582. X
  583. XThese are the instructions to compile "help(L)":
  584. X
  585. X1.    Edit the file "global.h" and change the #define's
  586. X    for ROOTDIR, HELPFILE, and DIRFILE to be locally
  587. X    acceptable.
  588. X
  589. X2.    Edit the file "Makefile" and fix the definitions of BIN, HELPDIR,
  590. X    HELPOWN, and HELPGRP so that "make install" will work.
  591. X
  592. X3.    Type "make all".
  593. X
  594. X4.    IF the make completes, play around with it for a while
  595. X    and make sure it works...
  596. X
  597. X5.    Type "make install".  This will install a copy of our help
  598. X    files, complete with typo's & bad grammar.  Most of the
  599. X    files were typed in by various volunteers here within
  600. X    the university.  You may want to look at them as an
  601. X    example, you may want to delete them, who knows...
  602. X
  603. XI bet you think you are done...  HA!  HA!  HA!  That's a computer joke!
  604. XYou are just barely beginning.  Now comes the fun part. :-)
  605. X
  606. X6.    Type "cd <ROOTDIR>".
  607. X
  608. X7.    Start making your "./TEXT" and "./DIR" files.  The examples
  609. X    in this shell archive should prove adequate for examples.
  610. X    For a subtopic, type "mkdir <subtopic>" and then
  611. X    "cd <subtopic>" and goto step 7.
  612. X
  613. XIf you have any questions or further enhancements (or help subtrees :-),
  614. Xplease e-mail them to me.  I really would like to hear how this thing
  615. Xfairs in the big wide world...
  616. X
  617. XRoland Stolfa
  618. XComputing and Information Sciences Department
  619. XOklahoma State University
  620. X219 Math Sciences Building
  621. XStillwater OK 74078
  622. X
  623. Xrjs@a.cs.okstate.edu
  624. END_OF_FILE
  625. if test 4091 -ne `wc -c <'help/README'`; then
  626.     echo shar: \"'help/README'\" unpacked with wrong size!
  627. fi
  628. # end of 'help/README'
  629. fi
  630. if test -f 'help/append.c' -a "${1}" != "-c" ; then 
  631.   echo shar: Will not clobber existing file \"'help/append.c'\"
  632. else
  633. echo shar: Extracting \"'help/append.c'\" \(1008 characters\)
  634. sed "s/^X//" >'help/append.c' <<'END_OF_FILE'
  635. X/*
  636. X * Program    : help
  637. X * Module    : append.c
  638. X * Programmer    : R. Stolfa
  639. X *
  640. X * Purpose :    To append a basename and help topic to the
  641. X *        specified list
  642. X *
  643. X * Modification History:
  644. X *   08/27/87    Created
  645. X *   08/31/87    Changed exit on default to be a call to "catch()"
  646. X *    -    Streamlined the building of nodes
  647. X */
  648. X
  649. X#include    "global.h"
  650. X
  651. Xappend (cmd, basename, subject, command)
  652. Xint    cmd;
  653. Xchar    *basename,
  654. X    *subject,
  655. X    *command;
  656. X{
  657. X    struct    LIST    *new;
  658. X
  659. X    if ((strlen (basename) == 0) ||
  660. X        (strlen (subject) == 0) ||
  661. X        (cmd < 0) || (cmd >= 3))
  662. X        /*
  663. X         * Bad invocation of "append()"
  664. X         */
  665. X        return;
  666. X
  667. X    /*
  668. X     * Build the basic LIST structure for the new
  669. X     * entry
  670. X     */
  671. X    new = (struct LIST *)
  672. X        malloc (sizeof (struct LIST));
  673. X  if(new==NULL){
  674. X     fprintf(stderr,"Can't malloc %d bytes\n",sizeof (struct LIST));
  675. X     exit(1);
  676. X  }
  677. X    strcpy (new->base, basename);
  678. X    strcpy (new->topic, subject);
  679. X    strcpy (new->cmd, command);
  680. X
  681. X    /*
  682. X     * Append the new element onto the correct list
  683. X     */
  684. X    new->prev = _list[cmd];
  685. X    _list[cmd] = new;
  686. X}
  687. END_OF_FILE
  688. if test 1008 -ne `wc -c <'help/append.c'`; then
  689.     echo shar: \"'help/append.c'\" unpacked with wrong size!
  690. fi
  691. # end of 'help/append.c'
  692. fi
  693. if test -f 'help/catch.c' -a "${1}" != "-c" ; then 
  694.   echo shar: Will not clobber existing file \"'help/catch.c'\"
  695. else
  696. echo shar: Extracting \"'help/catch.c'\" \(460 characters\)
  697. sed "s/^X//" >'help/catch.c' <<'END_OF_FILE'
  698. X/*
  699. X * Program    : help
  700. X * Module    : catch.c
  701. X * Programmer    : R. Stolfa
  702. X *
  703. X * Purpose :    To handle all user signals.
  704. X *
  705. X * Modification History:
  706. X *   08/31/87    Created
  707. X */
  708. X
  709. X#include    "global.h"
  710. X
  711. X#ifdef __TURBOC__
  712. X  void catch()
  713. X#else
  714. X  int    catch()
  715. X#endif
  716. X{
  717. X    /*
  718. X     * Free the in memory lists to keep user memory from
  719. X     * growing.
  720. X     */
  721. X    free_list (PRINT);
  722. X    free_list (ACRON);
  723. X    free_list (TOPIC);
  724. X
  725. X    /*
  726. X     * ...Neat up the screen and exit
  727. X     */
  728. X    putchar ('\n');
  729. X    exit (0);
  730. X}
  731. END_OF_FILE
  732. if test 460 -ne `wc -c <'help/catch.c'`; then
  733.     echo shar: \"'help/catch.c'\" unpacked with wrong size!
  734. fi
  735. # end of 'help/catch.c'
  736. fi
  737. if test -f 'help/format_help.c' -a "${1}" != "-c" ; then 
  738.   echo shar: Will not clobber existing file \"'help/format_help.c'\"
  739. else
  740. echo shar: Extracting \"'help/format_help.c'\" \(884 characters\)
  741. sed "s/^X//" >'help/format_help.c' <<'END_OF_FILE'
  742. X/*
  743. X * Program    : help
  744. X * Module    : format_help.c
  745. X * Programmer    : R. Stolfa
  746. X *
  747. X * Purpose :    To format the list of available help topics in a
  748. X *        neat and readable format
  749. X *
  750. X * Modification History:
  751. X *   08/26/87    Created
  752. X *   09/02/87    Fixed for more than one line of text (oops!),
  753. X *        streamlined.
  754. X */
  755. X
  756. X#include    "global.h"
  757. X
  758. Xformat_help ()
  759. X{
  760. X    struct    LIST    *p;        /* temporary LIST pointer */
  761. X    register    int    cur_col;
  762. X
  763. X    /*
  764. X     * Screen columns go from 0 to 79
  765. X     */
  766. X    cur_col = 0;
  767. X
  768. X    pchar ('\n');
  769. X    for (p = prt_list; p != NULL; p = p->prev) {
  770. X        /*
  771. X         * If the addition of the current topic to the screen
  772. X         * will cause there to be wraparound, skip to the next
  773. X         * line.
  774. X         */
  775. X        cur_col = (cur_col + 8) -
  776. X              ((cur_col + 8) % 8) +
  777. X              strlen(p->topic);
  778. X        if (cur_col > 79)  {
  779. X            cur_col = strlen(p->topic) + 8;
  780. X            pchar ('\n');
  781. X        }
  782. X        printf ("\t%s", p->topic);
  783. X    }
  784. X    pchar ('\n');
  785. X    pchar ('\n');
  786. X}
  787. END_OF_FILE
  788. if test 884 -ne `wc -c <'help/format_help.c'`; then
  789.     echo shar: \"'help/format_help.c'\" unpacked with wrong size!
  790. fi
  791. # end of 'help/format_help.c'
  792. fi
  793. if test -f 'help/free_list.c' -a "${1}" != "-c" ; then 
  794.   echo shar: Will not clobber existing file \"'help/free_list.c'\"
  795. else
  796. echo shar: Extracting \"'help/free_list.c'\" \(634 characters\)
  797. sed "s/^X//" >'help/free_list.c' <<'END_OF_FILE'
  798. X/*
  799. X * Program    : help
  800. X * Module    : free_list.c
  801. X * Programmer    : R. Stolfa
  802. X *
  803. X * Purpose :    To return to system memory a list of LIST structures
  804. X *
  805. X * Modification History:
  806. X *   08/27/87    Created
  807. X *   08/31/87    Changed default exit to be a call to "catch()"
  808. X */
  809. X
  810. X#include    "global.h"
  811. X
  812. Xfree_list (type)
  813. Xint    type;
  814. X{
  815. X    struct    LIST    *q;
  816. X
  817. X    /*
  818. X     * Check for valid type
  819. X     */
  820. X    if ((type < 0) || (type >= 3)) {
  821. X        printf ("free_list:  error in type parameter %d\n", type);
  822. X        catch ();
  823. X        /* NOT REACHED */
  824. X    }
  825. X
  826. X    /*
  827. X     * Clear the header
  828. X     */
  829. X    q = _list[type];
  830. X    _list[type] = NULL;
  831. X
  832. X    /*
  833. X     * Clear the list
  834. X     */
  835. X    for ( ; q != NULL; q = q->prev)
  836. X        free (q);
  837. X}
  838. END_OF_FILE
  839. if test 634 -ne `wc -c <'help/free_list.c'`; then
  840.     echo shar: \"'help/free_list.c'\" unpacked with wrong size!
  841. fi
  842. # end of 'help/free_list.c'
  843. fi
  844. if test -f 'help/global.h' -a "${1}" != "-c" ; then 
  845.   echo shar: Will not clobber existing file \"'help/global.h'\"
  846. else
  847. echo shar: Extracting \"'help/global.h'\" \(2295 characters\)
  848. sed "s/^X//" >'help/global.h' <<'END_OF_FILE'
  849. X/*
  850. X * Program    : help
  851. X * Module    : global.h
  852. X * Programmer    : R. Stolfa
  853. X *
  854. X * Modification History:
  855. X *   08/27/87    Created
  856. X *   07/13/88    Cleaned up for distribution
  857. X */
  858. X
  859. X#include    <stdio.h>
  860. X#ifdef __TURBOC__
  861. X#include <stdlib.h>
  862. X#endif
  863. X#include    <signal.h>
  864. X#include    <ctype.h>
  865. X#undef        toupper            /* to get the non-macro version */
  866. X
  867. X#define        TRUE        1
  868. X#define        FALSE        0
  869. X#define        UP        2
  870. X
  871. X#define        BSIZE        80
  872. X
  873. X#define        PRINT        0
  874. X#define        ACRON        1
  875. X#define        TOPIC        2
  876. X
  877. X/*
  878. X * ROOTDIR is the anchor point for the help tree.  It should be a
  879. X * publically accessable directory, with all it's submembers being
  880. X * readable and executable by all.
  881. X */
  882. X#define        ROOTDIR        "/usr/local/help"
  883. X
  884. X/*
  885. X * HELPFILE is the basename of the file that will contain the
  886. X * text of the actual help information.  It should have
  887. X * permissions 444.
  888. X */
  889. X#define        HELPFILE    "/TEXT"
  890. X
  891. X/*
  892. X * DIRFILE is the basename of a file that contains the help
  893. X * index to file name mappings for the current level of the
  894. X * help tree.  The format of the data contained in this file
  895. X * is as follows....
  896. X *
  897. X * <basename><print_flag><help_index_string>
  898. X *
  899. X * where:
  900. X *    <basename>    relative directory name for help
  901. X *    <print_flag>    is a:
  902. X *                * for printable
  903. X *                : for acronym
  904. X *    <help_index_string>
  905. X *            text to present as a choice (or use as an
  906. X *            acronym) at any level in the help tree
  907. X */
  908. X#define        DIRFILE        "/DIR"
  909. X
  910. X/*
  911. X * LIST structure.
  912. X *
  913. X * This is the standard format of help file lists.
  914. X */
  915. Xstruct    LIST {
  916. X    char    base[BSIZE];
  917. X    char    topic[BSIZE];
  918. X    char    cmd[BSIZE];
  919. X    struct    LIST    *prev;
  920. X};
  921. X#define        prt_list    (_list[PRINT])
  922. X#define        acr_list    (_list[ACRON])
  923. X#define        top_list    (_list[TOPIC])
  924. X
  925. X/*------------------------------------------------------------*/
  926. X
  927. X/*
  928. X * MACROS
  929. X */
  930. X
  931. X#define    gen_path(x)    sprintf (Path, "%s%s%s", Root_Dir, cur_path, (x))
  932. X
  933. X/*------------------------------------------------------------*/
  934. X
  935. X/*
  936. X * Variables
  937. X */
  938. X
  939. X#ifdef    MAIN
  940. X#define    extern    /* global */
  941. X#endif
  942. X
  943. Xextern    struct    LIST    *_list[3];    /* list of printable topics */
  944. Xextern    char        Path[BSIZE],    /* true path to help file */
  945. X            cur_path[BSIZE];/* curent help path */
  946. Xextern    int        lines;        /* number of lines on the screen */
  947. X#ifdef __TURBOC__
  948. X          void catch();    /* interrupt handler */
  949. X#else
  950. X          int catch();
  951. X#endif
  952. Xextern    char        Root_Dir[BSIZE];/* location of root directory */
  953. END_OF_FILE
  954. if test 2295 -ne `wc -c <'help/global.h'`; then
  955.     echo shar: \"'help/global.h'\" unpacked with wrong size!
  956. fi
  957. # end of 'help/global.h'
  958. fi
  959. if test -f 'help/help.1' -a "${1}" != "-c" ; then 
  960.   echo shar: Will not clobber existing file \"'help/help.1'\"
  961. else
  962. echo shar: Extracting \"'help/help.1'\" \(2516 characters\)
  963. sed "s/^X//" >'help/help.1' <<'END_OF_FILE'
  964. X.TH HELP L
  965. X.SH NAME
  966. Xhelp - a VMS-like help facility for XENIX
  967. X.SH SYNOPSIS
  968. X.B help
  969. X.br
  970. X.SH DESCRIPTION
  971. X.I help
  972. Xis intended to be a more useful system than the native
  973. X.I man(1)
  974. Xsupplied with
  975. X.I XENIX.
  976. XIt is styled after the very popular and useful VMS HELP facility, in that
  977. Xit is tree structured and interactive.
  978. X.PP
  979. X.I help
  980. Xis very configurable.  In essence, you decide what help "topics" map
  981. Xto what files.  I.E. you can have more than one topic, or acronym, map
  982. Xto the same help subtopic.  An example would be having the words "lp"
  983. Xand "printing" both map to the 
  984. X.I help
  985. Xsubtopic "lp-command".  Also, you need not have the subtopic "lp" even
  986. Xshow up in the help screen.  If you wish to have acronyms, as described
  987. Xabove, it is site taylorable using the DIRFILE (as described below in
  988. XINTERNALS).
  989. X.PP
  990. XAll of the files and directories contained in the system are all plain
  991. Xtext files, with an easy format that can be used to your advantage.
  992. X.sp 1
  993. X.SH "INTERNALS"
  994. X.I help
  995. Xuses a tree structured file data-base to store all help.  Each node (or
  996. Xdirectory) has at least one file.  This file, called
  997. X.I ./TEXT
  998. Xcontains the actual text of the help message for this subtopic.  If there
  999. Xare any subtopics below this one, their
  1000. X.I ./TEXT
  1001. Xfiles are held in subdirectories of this one, and then there is a file
  1002. X.I ./DIR
  1003. Xthat maps the directory name to the subtopic to display.  This will allow
  1004. X.I SYSV
  1005. Xsystems with limited directory name lengths map much longer descriptions
  1006. Xto shorter file names.
  1007. X.PP
  1008. XAlso contained in the
  1009. X.I ./DIR
  1010. Xfile is a similar mapping for acronyms of the subsequent subtopics.  In the
  1011. Xexample above with lp, a sample portion of a help file would be
  1012. X.sp 1
  1013. X    lp-command*lp
  1014. X.br
  1015. X    lp-command:printing
  1016. X.br
  1017. X    lp-command:getting output
  1018. X.sp 1
  1019. XWhere the "*" in the first line implies that the "topic" name "lp" is to
  1020. Xbe printed as a possible topic for help, and the subtopics "printing" and
  1021. X"getting output" are acronyms for traversing the to the "lp-command"
  1022. Xsubdirectory to get at the next
  1023. X.I ./TEXT
  1024. Xfile.
  1025. X.sp 1
  1026. X.SH "FILES"
  1027. X"/usr/help/...."    - Root directory for help
  1028. X.br
  1029. X"./TEXT"            - Help text
  1030. X.br
  1031. X"./DIR"            - Directory files for next subtopic
  1032. X.PP
  1033. X.SH DIAGNOSTICS
  1034. XThere are no real diagnostics.  However, if you reach a point in the
  1035. Xhelp system where you know you have a "subtopic" but cannot reach it,
  1036. Xsearch for correct premissions (0444 for
  1037. X.I ./TEXT
  1038. Xfiles, and (0555 for
  1039. X.I ./DIR
  1040. Xfiles).
  1041. X.sp 1
  1042. X.SH AUTHOR
  1043. XRoland J. Stolfa
  1044. X.br
  1045. XDepartment of Computing and Information Sciences
  1046. X.br
  1047. XOklahoma State University
  1048. X
  1049. END_OF_FILE
  1050. if test 2516 -ne `wc -c <'help/help.1'`; then
  1051.     echo shar: \"'help/help.1'\" unpacked with wrong size!
  1052. fi
  1053. # end of 'help/help.1'
  1054. fi
  1055. if test -f 'help/help.c' -a "${1}" != "-c" ; then 
  1056.   echo shar: Will not clobber existing file \"'help/help.c'\"
  1057. else
  1058. echo shar: Extracting \"'help/help.c'\" \(749 characters\)
  1059. sed "s/^X//" >'help/help.c' <<'END_OF_FILE'
  1060. X/*
  1061. X * Program    : help
  1062. X * Module    : help.c
  1063. X * Programmer    : R. Stolfa
  1064. X *
  1065. X * Purpose :    To more the current "HELPFILE" to the screen.
  1066. X *
  1067. X * Modification History:
  1068. X *   08/27/87    Created
  1069. X *   09/02/87    Added ("Q"|"q") commands
  1070. X */
  1071. X
  1072. X#include    "global.h"
  1073. X
  1074. Xhelp ()
  1075. X{
  1076. X    FILE    *fd;        /* help text file */
  1077. X    int    c;        /* temp */
  1078. X
  1079. X    gen_path (HELPFILE);
  1080. X
  1081. X    if ((fd = fopen (Path, "r")) == NULL) {
  1082. X        printf ("There is no help text on this subject\n");
  1083. X        return;
  1084. X    }
  1085. X
  1086. X    /*
  1087. X     * Note what help subject we are looking at
  1088. X     */
  1089. X    if (strlen (cur_path) != 0) {
  1090. X        present ("TOPIC: ", " ");
  1091. X        pchar ('\n');
  1092. X    }
  1093. X
  1094. X    /*
  1095. X     * Reset the number of lines displayed, and output
  1096. X     * the new help file text.
  1097. X     */
  1098. X    while ((c = getc (fd)) != EOF)
  1099. X        pchar(c);
  1100. X
  1101. X    fclose (fd);
  1102. X
  1103. X    pchar ('\n');
  1104. X    lines ++;
  1105. X}
  1106. END_OF_FILE
  1107. if test 749 -ne `wc -c <'help/help.c'`; then
  1108.     echo shar: \"'help/help.c'\" unpacked with wrong size!
  1109. fi
  1110. # end of 'help/help.c'
  1111. fi
  1112. if test -f 'help/initialize.c' -a "${1}" != "-c" ; then 
  1113.   echo shar: Will not clobber existing file \"'help/initialize.c'\"
  1114. else
  1115. echo shar: Extracting \"'help/initialize.c'\" \(433 characters\)
  1116. sed "s/^X//" >'help/initialize.c' <<'END_OF_FILE'
  1117. X/*
  1118. X * Program    : help
  1119. X * Module    : initialize.c
  1120. X * Programmer    : R. Stolfa
  1121. X *
  1122. X * Purpose :    To initialize all global data structures
  1123. X *
  1124. X * Modification History:
  1125. X *   08/31/87    Created
  1126. X */
  1127. X
  1128. X#include    "global.h"
  1129. X
  1130. Xinitialize()
  1131. X{
  1132. X    int    i;
  1133. X
  1134. X    /*
  1135. X     * Catch all signals that might not free up memory....
  1136. X     */
  1137. X    signal (SIGINT, catch);
  1138. X    signal (SIGTERM, catch);
  1139. X
  1140. X    Path[0] = '\0';
  1141. X    cur_path[0] = '\0';
  1142. X
  1143. X    for (i = 0; i < 3 ; i ++)
  1144. X        _list[i] = NULL;
  1145. X}
  1146. END_OF_FILE
  1147. if test 433 -ne `wc -c <'help/initialize.c'`; then
  1148.     echo shar: \"'help/initialize.c'\" unpacked with wrong size!
  1149. fi
  1150. # end of 'help/initialize.c'
  1151. fi
  1152. if test -f 'help/input_choice.c' -a "${1}" != "-c" ; then 
  1153.   echo shar: Will not clobber existing file \"'help/input_choice.c'\"
  1154. else
  1155. echo shar: Extracting \"'help/input_choice.c'\" \(2709 characters\)
  1156. sed "s/^X//" >'help/input_choice.c' <<'END_OF_FILE'
  1157. X/*
  1158. X * Program    : help
  1159. X * Module    : input_choice.c
  1160. X * Programmer    : R. Stolfa
  1161. X *
  1162. X * Purpose :    To selectively change the current help subject
  1163. X *        based on what topic the user chooses to learn
  1164. X *        about next.
  1165. X *
  1166. X * Modification History:
  1167. X *   08/26/87    Created
  1168. X */
  1169. X
  1170. X#include    "global.h"
  1171. X
  1172. Xinput_choice ()
  1173. X{
  1174. X    int    done,            /* need to parse DIRFILE again */
  1175. X        i,            /* temp */
  1176. X        j,            /* temp */
  1177. X        count,            /* num. of acronym topics that mached */
  1178. X        topics;            /* num. of topics at this level */
  1179. X    char    buff[BSIZE],        /* input buffer */
  1180. X        tmp_path[BSIZE];    /* holding place for cur_path */
  1181. X    struct    LIST    *p;        /* temp */
  1182. X
  1183. X    done = FALSE;
  1184. X    do {
  1185. X        present ("HELP ", " > ");
  1186. X
  1187. X        if (fgets (buff, BSIZE, stdin) == NULL)
  1188. X            /*
  1189. X             * End help on EOF
  1190. X             */
  1191. X            return (TRUE);
  1192. X
  1193. X        /*
  1194. X         * Strip junk out of line
  1195. X         */
  1196. X        for (i = 0, j = 0; i < strlen(buff); i ++) {
  1197. X            if (buff[i] == '\n')
  1198. X                buff[i] = '\0';
  1199. X            if (!isspace(buff[i]))
  1200. X                buff[j++] = toupper(buff[i]);
  1201. X        }
  1202. X
  1203. X        if (strlen(buff) == 0) {
  1204. X            /*
  1205. X             * At this point, we have a request to recurse
  1206. X             * back out of the help tree by one level.
  1207. X             */
  1208. X            for (i = strlen (cur_path); cur_path[i] != '/'; --i)
  1209. X                ;
  1210. X            cur_path[i] = '\0';
  1211. X            return (UP);
  1212. X            /* NOT REACHED */
  1213. X        }
  1214. X
  1215. X        /*
  1216. X         * OK.  We have the topic that the user has requested.
  1217. X         * Now let's try to find some reference to it
  1218. X         */
  1219. X        count = 0;
  1220. X        topics = 0;
  1221. X        free_list (TOPIC);
  1222. X        for (p = acr_list; p != NULL ; p = p->prev) {
  1223. X            if (strncmp (buff, p->topic, strlen(buff)) == 0) {
  1224. X                insert (TOPIC,
  1225. X                    p->base, p->topic, p->cmd);
  1226. X                count ++;
  1227. X            }
  1228. X            topics ++;
  1229. X        }
  1230. X
  1231. X        if (count == 0) {
  1232. X            if (strcmp (buff, "?") != 0) {
  1233. X                present ("Sorry, no documentation on ", " ");
  1234. X                printf ("%s\n", buff);
  1235. X            }
  1236. X            if (topics > 0) {
  1237. X                printf ("Additional information available:\n");
  1238. X                lines = 2;
  1239. X                format_help();
  1240. X            }
  1241. X            done = FALSE;
  1242. X        } else if (count == 1) {
  1243. X            if (top_list->cmd[0] == '\0') {
  1244. X               /*
  1245. X                * We have only one help subtopic, so traverse
  1246. X                * the tree down that link.
  1247. X                */
  1248. X               sprintf (cur_path, "%s/%s", cur_path,
  1249. X                   top_list->base);
  1250. X               done = TRUE;
  1251. X                           }
  1252. X            else {
  1253. X                           system(top_list->cmd);
  1254. X                           return (UP);
  1255. X                           }
  1256. X        } else {
  1257. X            /*
  1258. X             * We have several matches.  Therefore, page the
  1259. X             * HELPFILE for each to the screen and stay where
  1260. X             * we are.
  1261. X             */
  1262. X            lines = 0;
  1263. X            strcpy (tmp_path, cur_path);
  1264. X            for (p = top_list; p != NULL ; p = p->prev) {
  1265. X                if (p->cmd[0] == '\0') {
  1266. X                   sprintf (cur_path, "%s/%s", tmp_path,
  1267. X                       p->base);
  1268. X                   gen_path(HELPFILE);
  1269. X                   help();
  1270. X                   strcpy (cur_path, tmp_path);
  1271. X                   }
  1272. X            }
  1273. X        }
  1274. X
  1275. X    } while (done != TRUE);
  1276. X    return (FALSE);
  1277. X}
  1278. END_OF_FILE
  1279. if test 2709 -ne `wc -c <'help/input_choice.c'`; then
  1280.     echo shar: \"'help/input_choice.c'\" unpacked with wrong size!
  1281. fi
  1282. # end of 'help/input_choice.c'
  1283. fi
  1284. if test -f 'help/insert.c' -a "${1}" != "-c" ; then 
  1285.   echo shar: Will not clobber existing file \"'help/insert.c'\"
  1286. else
  1287. echo shar: Extracting \"'help/insert.c'\" \(1087 characters\)
  1288. sed "s/^X//" >'help/insert.c' <<'END_OF_FILE'
  1289. X/*
  1290. X * Program    : help
  1291. X * Module    : insert.c
  1292. X * Programmer    : R. Stolfa
  1293. X *
  1294. X * Purpose :    To uniquely insert a basename and help topic to the
  1295. X *        specified list
  1296. X *
  1297. X * Modification History:
  1298. X *   07/13/88    Created
  1299. X */
  1300. X
  1301. X#include    "global.h"
  1302. X
  1303. Xinsert (cmd, basename, subject, command)
  1304. Xint    cmd;
  1305. Xchar    *basename,
  1306. X    *subject,
  1307. X    *command;
  1308. X{
  1309. X    struct    LIST    *new, *p;
  1310. X
  1311. X    if ((strlen (basename) == 0) ||
  1312. X        (strlen (subject) == 0) ||
  1313. X        (cmd < 0) || (cmd >= 3))
  1314. X        /*
  1315. X         * Bad invocation of "insert()"
  1316. X         */
  1317. X        return;
  1318. X
  1319. X    /*
  1320. X     * Build the basic LIST structure for the new
  1321. X     * entry
  1322. X     */
  1323. X    new = (struct LIST *)
  1324. X        malloc (sizeof (struct LIST));
  1325. X    strcpy (new->base, basename);
  1326. X    strcpy (new->topic, subject);
  1327. X    strcpy (new->cmd, command);
  1328. X
  1329. X    /*
  1330. X     * Prepend the new element onto the correct list
  1331. X     */
  1332. X    p = _list[cmd];
  1333. X    new->prev = _list[cmd];
  1334. X
  1335. X    /*
  1336. X     * Check for uniqueness
  1337. X     */
  1338. X    for (; p != NULL; p = p->prev) {
  1339. X        if (strcmp (new->base, p->base) == 0) {
  1340. X            free (new);
  1341. X            return;
  1342. X            /* NOT REACHED */
  1343. X        }
  1344. X    }
  1345. X
  1346. X    /*
  1347. X     * If we get to here, we have a new item.  Fix the master
  1348. X     * pointer & go on.
  1349. X     */
  1350. X    _list[cmd] = new;
  1351. X}
  1352. END_OF_FILE
  1353. if test 1087 -ne `wc -c <'help/insert.c'`; then
  1354.     echo shar: \"'help/insert.c'\" unpacked with wrong size!
  1355. fi
  1356. # end of 'help/insert.c'
  1357. fi
  1358. if test -f 'help/link.otc' -a "${1}" != "-c" ; then 
  1359.   echo shar: Will not clobber existing file \"'help/link.otc'\"
  1360. else
  1361. echo shar: Extracting \"'help/link.otc'\" \(159 characters\)
  1362. sed "s/^X//" >'help/link.otc' <<'END_OF_FILE'
  1363. X\tc\lib\C0l main append catch format_h free_lis help insert initiali input_ch pchar present scan_top,help,help, \tc\lib\emu \tc\lib\mathl \tc\lib\cl 
  1364. X        
  1365. END_OF_FILE
  1366. if test 159 -ne `wc -c <'help/link.otc'`; then
  1367.     echo shar: \"'help/link.otc'\" unpacked with wrong size!
  1368. fi
  1369. # end of 'help/link.otc'
  1370. fi
  1371. if test -f 'help/main.c' -a "${1}" != "-c" ; then 
  1372.   echo shar: Will not clobber existing file \"'help/main.c'\"
  1373. else
  1374. echo shar: Extracting \"'help/main.c'\" \(1359 characters\)
  1375. sed "s/^X//" >'help/main.c' <<'END_OF_FILE'
  1376. X/*
  1377. X * Program    : help
  1378. X * Module    : main.c
  1379. X * Programmer    : R. Stolfa
  1380. X *
  1381. X * Purpose :    To support a VMS-like help facility
  1382. X *
  1383. X * Modification History:
  1384. X *   08/26/87    Created
  1385. X *   07/13/88    Fixed end-of-program detection to work correctly
  1386. X */
  1387. X
  1388. X#define        MAIN
  1389. X#include    "global.h"
  1390. X
  1391. Xmain (argc, argv)
  1392. Xint    argc;
  1393. Xchar    *argv[];
  1394. X{
  1395. X    int    done;
  1396. X    char *helpdir, *getenv();
  1397. X
  1398. X        --argc; ++argv;
  1399. X
  1400. X        if ((helpdir = getenv ("HELPDIR")) == NULL)
  1401. X           strcpy(Root_Dir, ROOTDIR);
  1402. X        else
  1403. X           strcpy (Root_Dir, helpdir);
  1404. X
  1405. X        if (argc >= 2 && strcmp(*argv,"-r") == 0) {    /* Absolute directory */
  1406. X           strcpy(Root_Dir, *++argv);
  1407. X           ++argv;
  1408. X           argc += 2;
  1409. X        }
  1410. X                
  1411. X        while (argc--) {        /* Construct relative root directory */
  1412. X           strcat(Root_Dir,"/");
  1413. X           strcat(Root_Dir, *argv);
  1414. X           ++argv;
  1415. X        }
  1416. X
  1417. X    initialize();
  1418. X    done = FALSE;
  1419. X
  1420. X    while (done != TRUE) {
  1421. X        /*
  1422. X         * Free memory to keep user memory from growing
  1423. X         */
  1424. X        free_list (PRINT);
  1425. X        free_list (ACRON);
  1426. X        free_list (TOPIC);
  1427. X
  1428. X        /*
  1429. X         * If we are recursing out of the help tree,
  1430. X         * do not print the help stuff...
  1431. X         */
  1432. X        lines = 0;
  1433. X        if (done != UP)
  1434. X            help();
  1435. X        scan_topics ();
  1436. X        if (done != UP)
  1437. X            format_help ();
  1438. X        done = input_choice ();
  1439. X
  1440. X        if ((done == UP) && (strcmp (Path, Root_Dir) == 0))
  1441. X            done = TRUE;
  1442. X    }
  1443. X    printf ("\n");
  1444. Xexit(0);
  1445. X}
  1446. END_OF_FILE
  1447. if test 1359 -ne `wc -c <'help/main.c'`; then
  1448.     echo shar: \"'help/main.c'\" unpacked with wrong size!
  1449. fi
  1450. # end of 'help/main.c'
  1451. fi
  1452. if test -f 'help/makefile.tc' -a "${1}" != "-c" ; then 
  1453.   echo shar: Will not clobber existing file \"'help/makefile.tc'\"
  1454. else
  1455. echo shar: Extracting \"'help/makefile.tc'\" \(825 characters\)
  1456. sed "s/^X//" >'help/makefile.tc' <<'END_OF_FILE'
  1457. X#
  1458. X# HELP - Ver. 1.0
  1459. X#
  1460. X#        by R. Stolfa
  1461. X#
  1462. X# Modification History
  1463. X#  08/26/87    Created
  1464. X#  08/31/87    Added initialize and catch functions
  1465. X#  09/02/87    Added all .h dependencies
  1466. X#  07/13/88    Packaged to ship out of OSU
  1467. X#        Added insert to fix problem with uniqueness
  1468. X#
  1469. X
  1470. XOFILES    =\
  1471. X    main.obj append.obj catch.obj format_h.obj free_lis.obj help.obj insert.obj \
  1472. X    initiali.obj input_ch.obj pchar.obj present.obj scan_top.obj
  1473. X
  1474. Xhelp.exe: $(OFILES)
  1475. X  tlink /m /s /v /l @link.otc
  1476. X
  1477. XCFLAGS    = -c -f -ml -M -y -v -I\tc\include -DMSDOS -DPC
  1478. XCC      = tcc
  1479. X
  1480. X.c.obj:
  1481. X  tcc $(CFLAGS) $*
  1482. X  
  1483. Xmain.obj: main.c
  1484. Xappend.obj: append.c
  1485. Xcatch.obj: catch.c
  1486. Xformat_h.obj: format_h.c
  1487. Xfree_lis.obj: free_lis.c
  1488. Xhelp.obj: help.c
  1489. Xinsert.obj: insert.c
  1490. Xinitiali.obj: initiali.c
  1491. Xinput_ch.obj: input_ch.c
  1492. Xpchar.obj: pchar.c
  1493. Xpresent.obj: present.c
  1494. Xscan_top.obj: scan_top.c
  1495. END_OF_FILE
  1496. if test 825 -ne `wc -c <'help/makefile.tc'`; then
  1497.     echo shar: \"'help/makefile.tc'\" unpacked with wrong size!
  1498. fi
  1499. # end of 'help/makefile.tc'
  1500. fi
  1501. if test -f 'help/makefile.unx' -a "${1}" != "-c" ; then 
  1502.   echo shar: Will not clobber existing file \"'help/makefile.unx'\"
  1503. else
  1504. echo shar: Extracting \"'help/makefile.unx'\" \(1489 characters\)
  1505. sed "s/^X//" >'help/makefile.unx' <<'END_OF_FILE'
  1506. X#
  1507. X# HELP - Ver. 1.0
  1508. X#
  1509. X#        by R. Stolfa
  1510. X#
  1511. X# (For 3B1 shared libraries change the ld command below...)
  1512. X# Modification History
  1513. X#  08/26/87    Created
  1514. X#  08/31/87    Added initialize and catch functions
  1515. X#  09/02/87    Added all .h dependencies
  1516. X#  07/13/88    Packaged to ship out of OSU
  1517. X#        Added insert to fix problem with uniqueness
  1518. X#
  1519. X
  1520. XBIN    = /usr/local/bin
  1521. XHELPDIR    = /usr/local/help
  1522. XCFLAGS    = -O
  1523. XCC      = cc
  1524. X# HELPOWN = help
  1525. X# HELPGRP = root
  1526. XHELPOWN = bin
  1527. XHELPGRP = bin
  1528. X
  1529. XOFILES    =\
  1530. X    main.o append.o catch.o format_help.o free_list.o help.o insert.o \
  1531. X    initialize.o input_choice.o pchar.o present.o scan_topics.o
  1532. X
  1533. Xhelp:    $(OFILES)
  1534. X    $(CC) $(CFLAGS) $(OFILES) -o help
  1535. X#    ld /lib/crt0s.o /lib/shlib.ifile $(CFLAGS) $(OFILES) -o help
  1536. X
  1537. Xall:    help manual
  1538. X
  1539. Xinstall:
  1540. X    cp help $(BIN)
  1541. X    chmod 711 $(BIN)/help
  1542. X    chown $(HELPOWN) $(BIN)/help
  1543. X    chgrp $(HELPGRP) $(BIN)/help
  1544. X#    mkdir $(HELPDIR)
  1545. X#    cp files $(HELPDIR)
  1546. X#    cd $(HELPDIR) ; shar files
  1547. X#    @echo "Remember to fix the ownership & permissions"
  1548. X
  1549. Xmanual:
  1550. X    nroff -man man.form > help.man
  1551. X
  1552. Xclean:
  1553. X    rm -f *.o help a.out core help.man Help.shar
  1554. X
  1555. Xshar:
  1556. X    shar README Makefile *.h *.c man.form files > Help.shar
  1557. X
  1558. X#
  1559. X# Dependencies
  1560. X#
  1561. X
  1562. Xmain.o append.o catch.o format_help.o free_list.o help.o \
  1563. Xinitialize.o input_choice.o insert.o pchar.o present.o scan_topics.o \
  1564. X    : global.h
  1565. X
  1566. Xmain.o catch.o format_help.o free_list.o help.o \
  1567. Xinput_choice.o insert.o pchar.o scan_topics.c \
  1568. X    : /usr/include/stdio.h
  1569. X
  1570. Xinitialize.o \
  1571. X    : /usr/include/signal.h
  1572. X
  1573. Xinput_choice.o \
  1574. X    : /usr/include/ctype.h
  1575. END_OF_FILE
  1576. if test 1489 -ne `wc -c <'help/makefile.unx'`; then
  1577.     echo shar: \"'help/makefile.unx'\" unpacked with wrong size!
  1578. fi
  1579. # end of 'help/makefile.unx'
  1580. fi
  1581. if test -f 'help/pchar.c' -a "${1}" != "-c" ; then 
  1582.   echo shar: Will not clobber existing file \"'help/pchar.c'\"
  1583. else
  1584. echo shar: Extracting \"'help/pchar.c'\" \(736 characters\)
  1585. sed "s/^X//" >'help/pchar.c' <<'END_OF_FILE'
  1586. X/*
  1587. X * Program    : help
  1588. X * Module    : pchar.c
  1589. X * Programmer    : R. Stolfa
  1590. X *
  1591. X * Purpose :    To provide a very simple "more" like output stream for
  1592. X *        looking at the text in "HELPFILE" and all the topics
  1593. X *        listed in "DIRFILE".
  1594. X *
  1595. X * Modification History:
  1596. X *   08/27/87    Created
  1597. X */
  1598. X
  1599. X#include    "global.h"
  1600. X
  1601. Xpchar (c)
  1602. Xint    c;
  1603. X{
  1604. X    char    in_buff[BSIZE];        /* input buffer */
  1605. X
  1606. X    /*
  1607. X     * If this is the recursive call, do not
  1608. X     * output anything
  1609. X     */
  1610. X    if (c != '\0')
  1611. X        putchar (c);
  1612. X
  1613. X    /*
  1614. X     * If this is the newline, then increment the
  1615. X     * line count
  1616. X     */
  1617. X    if (c == '\n')
  1618. X        lines ++;
  1619. X
  1620. X    /*
  1621. X     * If this is the one to pause on, then do so
  1622. X     */
  1623. X    if (lines == 21) {
  1624. X        printf ("\nPress RETURN to continue");
  1625. X        (void) fgets (in_buff, BSIZE, stdin);
  1626. X        lines = 0;
  1627. X    }
  1628. X}
  1629. END_OF_FILE
  1630. if test 736 -ne `wc -c <'help/pchar.c'`; then
  1631.     echo shar: \"'help/pchar.c'\" unpacked with wrong size!
  1632. fi
  1633. # end of 'help/pchar.c'
  1634. fi
  1635. if test -f 'help/present.c' -a "${1}" != "-c" ; then 
  1636.   echo shar: Will not clobber existing file \"'help/present.c'\"
  1637. else
  1638. echo shar: Extracting \"'help/present.c'\" \(521 characters\)
  1639. sed "s/^X//" >'help/present.c' <<'END_OF_FILE'
  1640. X/*
  1641. X * Program    : help
  1642. X * Module    : present.c
  1643. X * Programmer    : R. Stolfa
  1644. X *
  1645. X * Purpose :    To generate a topics line without '/'s in it.
  1646. X *
  1647. X * Modification History:
  1648. X *   08/31/87    Created
  1649. X */
  1650. X
  1651. X#include    "global.h"
  1652. X
  1653. Xpresent (str1, str2)
  1654. Xchar    *str1,
  1655. X    *str2;
  1656. X{
  1657. X    int    i;        /* temp */
  1658. X
  1659. X    /*
  1660. X     * Make a line like "/vi/join/lines" more readable as
  1661. X     * " vi join lines"
  1662. X     */
  1663. X    printf ("%s", str1);
  1664. X    for (i = 0; i < strlen (cur_path); i ++)
  1665. X        if (cur_path[i] == '/')
  1666. X            putchar (' ');
  1667. X        else
  1668. X            putchar (cur_path[i]);
  1669. X    printf ("%s", str2);
  1670. X}
  1671. END_OF_FILE
  1672. if test 521 -ne `wc -c <'help/present.c'`; then
  1673.     echo shar: \"'help/present.c'\" unpacked with wrong size!
  1674. fi
  1675. # end of 'help/present.c'
  1676. fi
  1677. if test -f 'help/scan_topics.c' -a "${1}" != "-c" ; then 
  1678.   echo shar: Will not clobber existing file \"'help/scan_topics.c'\"
  1679. else
  1680. echo shar: Extracting \"'help/scan_topics.c'\" \(2536 characters\)
  1681. sed "s/^X//" >'help/scan_topics.c' <<'END_OF_FILE'
  1682. X/*
  1683. X * Program    : help
  1684. X * Module    : scan_topics.c
  1685. X * Programmer    : R. Stolfa
  1686. X *
  1687. X * Purpose :    To scan the current directory for all "topic"
  1688. X *        directories in the DIRFILE file.
  1689. X *
  1690. X * Modification History:
  1691. X *   08/26/87    Created
  1692. X *   08/31/87    Changed input routine to change spaces in the topic
  1693. X *        field to be underscores.
  1694. X */
  1695. X
  1696. X#include    "global.h"
  1697. X
  1698. Xscan_topics ()
  1699. X{
  1700. X    FILE    *fd;            /* DIRFILE descriptor */
  1701. X    int    i,j,k,            /* temp */
  1702. X        cmd,            /* directed to man page? */
  1703. X        count;            /* is there any help? */
  1704. X    char    buff[BSIZE],        /* for reading DIRFILE */
  1705. X        help_topic[BSIZE],    /* used to parse DIRFILE lines */
  1706. X        base_path[BSIZE],    /* used to parse DIRFILE lines */
  1707. X        cmd_buf[BSIZE],        /* used to parse DIRFILE lines */
  1708. X        prt_flag;        /* used to parse DIRFILE lines */
  1709. X
  1710. X    count = 0;
  1711. X    gen_path(DIRFILE);
  1712. X
  1713. X    if ((fd = fopen (Path, "r")) == NULL) {
  1714. X        printf ("There are no subtopics for this area.\n");
  1715. X        return;
  1716. X    }
  1717. X
  1718. X    /*
  1719. X     * Here we need to read in the lines in DIRFILE
  1720. X     * that are of the format
  1721. X     * <basename><print_flag><help_topic_string>
  1722. X     * and capitalize the <help_topic_string>.
  1723. X     *
  1724. X     * if <print_flag> is a "*" then the <help_topic_string> is
  1725. X     * for viewing.
  1726. X     *
  1727. X     * if <print_flag> is a ":" then it is an acronym for lookups.
  1728. X     *
  1729. X     * if find "!" before <print_flag> then there's a command.
  1730. X     */
  1731. X
  1732. X    while (fgets (buff, BSIZE, fd) != NULL) {
  1733. X
  1734. X        cmd = 0;
  1735. X        k = j = 0;
  1736. X        for (i = 0;
  1737. X             i < strlen(buff) && buff[i] != ':' && buff[i] != '*';
  1738. X             i ++) {
  1739. X            if (buff[i] == '!')
  1740. X               ++cmd;
  1741. X            else if (!cmd)
  1742. X               base_path[j++] = buff[i];
  1743. X            else
  1744. X               cmd_buf[k++] = buff[i];
  1745. X            }
  1746. X        base_path[j] = '\0';
  1747. X        cmd_buf[k]   = '\0';
  1748. X
  1749. X        if (i < strlen (buff))
  1750. X            prt_flag = buff[i];
  1751. X        else
  1752. X            /* Bad input line */
  1753. X            continue;
  1754. X
  1755. X        strcpy (help_topic, &buff[i+1]);
  1756. X        for (i = 0; i < strlen (help_topic); i ++) {
  1757. X            help_topic[i] = toupper (help_topic[i]);
  1758. X            if (help_topic[i] == ' ')
  1759. X                help_topic[i] = '_';
  1760. X            if (help_topic[i] == '\n')
  1761. X                help_topic[i] = '\0';
  1762. X        }
  1763. X
  1764. X        /*
  1765. X         * At this point, we have a fairly legal line,
  1766. X         * so, let's finish it off...
  1767. X         */
  1768. X
  1769. X        if ((strlen (base_path) == 0) || (strlen (help_topic) == 0))
  1770. X            continue;
  1771. X        count ++;
  1772. X
  1773. X        if (prt_flag == '*')
  1774. X            /*
  1775. X             * Append this line to the list of things to
  1776. X             * output as topics
  1777. X             */
  1778. X            append (PRINT, base_path, help_topic, cmd_buf);
  1779. X
  1780. X        /*
  1781. X         * Append this line to the list of acronymns
  1782. X         * for reference later...
  1783. X         */
  1784. X        append (ACRON, base_path, help_topic, cmd_buf);
  1785. X    }
  1786. X
  1787. X    fclose (fd);
  1788. X
  1789. X    if (count == 0) {
  1790. X        printf ("There are no subtopics for this area.\n");
  1791. X        return;
  1792. X    }
  1793. X}
  1794. END_OF_FILE
  1795. if test 2536 -ne `wc -c <'help/scan_topics.c'`; then
  1796.     echo shar: \"'help/scan_topics.c'\" unpacked with wrong size!
  1797. fi
  1798. # end of 'help/scan_topics.c'
  1799. fi
  1800. echo shar: End of archive 7 \(of 7\).
  1801. cp /dev/null ark7isdone
  1802. MISSING=""
  1803. for I in 1 2 3 4 5 6 7 ; do
  1804.     if test ! -f ark${I}isdone ; then
  1805.     MISSING="${MISSING} ${I}"
  1806.     fi
  1807. done
  1808. if test "${MISSING}" = "" ; then
  1809.     echo You have unpacked all 7 archives.
  1810.     rm -f ark[1-9]isdone
  1811. else
  1812.     echo You still need to unpack the following archives:
  1813.     echo "        " ${MISSING}
  1814. fi
  1815. ##  End of shell archive.
  1816. exit 0
  1817.